{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "第二章"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xiaomi\n"
     ]
    }
   ],
   "source": [
    "#2.1\n",
    "message='xiaomi'\n",
    "print(message)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change_xiaomi\n"
     ]
    }
   ],
   "source": [
    "#2.2\n",
    "message='change_xiaomi'\n",
    "print(message)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello,Eric,would you like to learn some Python today?\n",
      "ERIC\n",
      "eric\n",
      "Eric\n",
      "Albert Einsteinonce said,A person who never made a mistake never tried anything new.\n",
      "Albert Einsteinonce said,A person who never made a mistake never tried anything new.\n",
      "\tAlbert Einstein\t\n",
      "\n",
      "\tAlbert Einstein\n",
      "Albert Einstein\t\n",
      "\n",
      "Albert Einstein\n"
     ]
    }
   ],
   "source": [
    "#2.3\n",
    "name='Eric'\n",
    "print(f'Hello,{name},would you like to learn some Python today?')\n",
    "#2.4\n",
    "print(name.upper())\n",
    "print(name.lower())\n",
    "print(name.title())\n",
    "#2.5 2.6\n",
    "famous_person='Albert Einstein'\n",
    "famous_quote='A person who never made a mistake never tried anything new.'\n",
    "print(f\"{famous_person}once said,{famous_quote}\")\n",
    "#2.7\n",
    "message=f\"{famous_person}once said,{famous_quote}\"\n",
    "print(message)\n",
    "#2.8\n",
    "famous_person='\\tAlbert Einstein\\t\\n'\n",
    "print(famous_person)\n",
    "print(famous_person.rstrip())\n",
    "print(famous_person.lstrip())\n",
    "print(famous_person.strip())\n",
    "#2.9\n",
    "filename='python_notes.txt'\n",
    "#removesuffix()在python3.9中才有\n",
    "#print(filename.removesuffix('.txt'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "8\n",
      "8\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "#2.9\n",
    "print(5+3)\n",
    "print(10-2)\n",
    "print(2*4)\n",
    "print(int(16/2))\n",
    "#2.10\n",
    "fn=8\n",
    "print(f\"my favorite number is {fn}\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#3.1 3.2\n",
    "names=['xiaomi','xiaohong','xiaoming']\n",
    "for name in names:\n",
    "    print(name)\n",
    "    print(f\"hello,{name.title()}\")\n",
    "commute=['b']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "tpp",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
